<?php
if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Mobile_Index_module extends CI_Module
{
    public $data;
    public $sid ;
    public function __construct(){
        parent::__construct();
        $this->sid = $GLOBALS['sid'];
        $this->data = $GLOBALS['config'];
        $this->load->model('admin.Adminuser_model');
        $this->load->model('line.Site_view_model');
        $this->load->model('weixin.weixin_model');
        $this->load->model('member.user_model');
    }

    public function clear()
    {

        $this->session->sess_destroy();
        redirect('mobile/index');

    }


    /**
     * 首页
     */
    public function index()
    {

        if ($_GET['qrcode'] == 1)
        {
            $this->load->library('QrCode');
            $qrCode = new QrCode();
            $file_dir = APPPATH . 'cache/qrcode/';
            dmkdir($file_dir);
            $qr_str = site_url('mobile/index?touchtpl=' . $_GET['touchtpl'] . '&preview=', $_GET['preview']) . (DEBUG ? '&debug=zlb' : '');
            $file_name = 'qr_' . md5($qr_str) . '.png';
            $file = $file_dir . $file_name;
            $qrCode->setText($qr_str);
            $qrCode->setSize(200);
            $qrCode->setPadding(10);
            $qrCode->save($file);
            mkdir(URLPRE . 'application/cache/qrcode');
            $qr_img = URLPRE . 'application/cache/qrcode/' . $file_name;
            echo "<img src='$qr_img' >";
            exit;
        }


        $this->data['common'] = array(
            array(
                'noback' => true,
                'head' => $this->data['sitename'],
                'title' => '我的历程',
                'keywords' => SITECITYNAME . '旅游网',
                'description' => SITECITYNAME . '旅游网-为您提供' . SITECITYNAME . '旅游资讯、' . SITECITYNAME . '旅游攻略、' . SITECITYNAME . '旅游线路，包括' . SITECITYNAME . '热门景区介绍、精彩游记、旅游地图、交通出行、游玩路线、旅游优惠信息、住宿、饮食、购物等旅游信息的综合性旅游门户网站。'
            )
        );


        $this->data['wechat'] = $this->weixin_model->db_get_setting();
        $this->data['site_logo'] = $GLOBALS['config']['sitelogo'];
        $this->data['company'] = $GLOBALS['config']['company'];


        $this->data['wechat']['weixincardtpl'] = 'touch';
        $this->load->view('weixincard/' . $this->data['wechat']['weixincardtpl'] . '/index', $this->data);



    }

    public function welcome()
    {
        $this->data['common'] = array(
            array(
                'noback' => TRUE,
                'head'   => $this->data['sitename']
            )
        );
        $city = $this->data['sitecityname'];
        $this->data['common'] = array(
            array(
                'noback' => TRUE,
                'head'   => $this->data['sitename'],
                'title'   => SITECITYNAME.'旅游网_'.SITECITYNAME.'旅游攻略',
                'keywords'   => SITECITYNAME.'旅游网',
                'description'   => SITECITYNAME.'旅游网-为您提供'.SITECITYNAME.'旅游资讯、'.SITECITYNAME.'旅游攻略、'.SITECITYNAME.'旅游线路，包括'.SITECITYNAME.'热门景区介绍、精彩游记、旅游地图、交通出行、游玩路线、旅游优惠信息、住宿、饮食、购物等旅游信息的综合性旅游门户网站。'
            )
        );
        $this->data['file_url'] = site_url('static/default/mobile/images/sq');
        $this->load->view(MOBILE_TEMPLATE_NAME.'/'.'welcome',$this->data);
    }

    /**
     * 公共头
     *
     * @param array $data
     */
    public function header($data = array()){


        $this->data = array_merge($this->data, $data);
        $this->load->view(MOBILE_TEMPLATE_NAME.'/'.'header', $this->data);
    }

    /**
     * 公共底部
     *
     * @param array $data
     */
    public function footer($data = array()){

        //移动端访问量统计
        $this->Site_view_model->update_data('mviews');
        $this->data = array_merge($this->data, $data);
        $this->load->view(MOBILE_TEMPLATE_NAME.'/'.'footer', $this->data);
    }


    public function tsms()
    {
        $this->user_model->_send_sms($this->data['notify_num'],2016,'');
    }
}